/*
 * @Description:icon字库封装
 * @Version: 2.0
 * @Autor: wiz
 * @Date: 2022-09-22 18:54:34
 * @LastEditors: wiz
 * @LastEditTime: 2022-12-09 11:28:32
 */
import lexicon from '@/lib/lexicon/index';
import axios from 'axios';

class T_iconFont {
  private icons: Set<string>;

  constructor() {
    this.icons = new Set();
    this.init();
  }

  private init(): void {
    axios.get(lexicon.url.getIconFontPath).then(res => {
      const data: string = res.data
        .replace(/\s*/g, '')
        .replace(/\\n/g, '')
        .replace(/\\r/g, '')
        .replace(/\\r\\n/g, '');

      data.split(':before').forEach(ele => {
        const bPos: number = ele.lastIndexOf('.');
        bPos > 0 && this.icons.add(ele.substring(bPos + 1));
      });
    });
  }

  public getIcons(): Set<string> {
    return this.icons;
  }
}
export { T_iconFont };
export interface I_iconFont extends T_iconFont {}
